# base class inherited by all items
class Question:
    
    def __init__(self, q_id, question):
        self.id = q_id
        self.question = question
        self.choices = {}
        self.answer = ""
        #self.choices = choices
        #self.answer = answer
        #=======================================================================
        # self.choices_index = 0
        #=======================================================================
    
        
    
    def add_choice(self, cvalue, ctext):
        c = Choice(cvalue,ctext)
        self.choices[c.get_id()] = c
    
    def set_answer(self, ans):
        self.answer = ans
    
    def get_id(self):
        return self.id
    
    def get_question(self):
        return self.question
    
    def get_choices(self):
        return self.choices
    
    def get_result(self, answer):
        if self.answer == answer:
            return True
        else:
            return False
    
    # display description of item.
    # should be overridden in subclass.
    def get_description(self):
        return "an object (not sure what it is)"
    
    # adds action to the actions list for this item
    def add_action(self,action_class):
        
        new_action = action_class()
        new_action.item = self
        self.actions[new_action.get_id()] = new_action
        return

class Choice:
    def __init__(self,choice_id,choice_text):
        self.id = choice_id
        self.text = choice_text
    
    def get_id(self):
        return self.id
    
    def get_text(self):
        return self.text

